package com.small.xx.ai.file.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 文件服务配置属性
 * 
 * @author xx-ai
 * @version 1.0.0
 */
@Component
@ConfigurationProperties(prefix = "app.file")
public class FileProperties {

    private Browser browser = new Browser();

    public Browser getBrowser() {
        return browser;
    }

    public void setBrowser(Browser browser) {
        this.browser = browser;
    }

    public static class Browser {
        private List<String> defaultPaths;
        private boolean allowSystemDirs = true;
        private long maxFileSizeDisplay = 1073741824L; // 1GB
        private boolean showHiddenFiles = false;
        private String defaultSortBy = "name";
        private String defaultSortOrder = "asc";
        private Security security = new Security();
        private Performance performance = new Performance();

        // Getters and Setters
        public List<String> getDefaultPaths() {
            return defaultPaths;
        }

        public void setDefaultPaths(List<String> defaultPaths) {
            this.defaultPaths = defaultPaths;
        }

        public boolean isAllowSystemDirs() {
            return allowSystemDirs;
        }

        public void setAllowSystemDirs(boolean allowSystemDirs) {
            this.allowSystemDirs = allowSystemDirs;
        }

        public long getMaxFileSizeDisplay() {
            return maxFileSizeDisplay;
        }

        public void setMaxFileSizeDisplay(long maxFileSizeDisplay) {
            this.maxFileSizeDisplay = maxFileSizeDisplay;
        }

        public boolean isShowHiddenFiles() {
            return showHiddenFiles;
        }

        public void setShowHiddenFiles(boolean showHiddenFiles) {
            this.showHiddenFiles = showHiddenFiles;
        }

        public String getDefaultSortBy() {
            return defaultSortBy;
        }

        public void setDefaultSortBy(String defaultSortBy) {
            this.defaultSortBy = defaultSortBy;
        }

        public String getDefaultSortOrder() {
            return defaultSortOrder;
        }

        public void setDefaultSortOrder(String defaultSortOrder) {
            this.defaultSortOrder = defaultSortOrder;
        }

        public Security getSecurity() {
            return security;
        }

        public void setSecurity(Security security) {
            this.security = security;
        }

        public Performance getPerformance() {
            return performance;
        }

        public void setPerformance(Performance performance) {
            this.performance = performance;
        }
    }

    public static class Security {
        private List<String> forbiddenPatterns;
        private List<String> allowedExtensions;
        private List<String> forbiddenExtensions;

        public List<String> getForbiddenPatterns() {
            return forbiddenPatterns;
        }

        public void setForbiddenPatterns(List<String> forbiddenPatterns) {
            this.forbiddenPatterns = forbiddenPatterns;
        }

        public List<String> getAllowedExtensions() {
            return allowedExtensions;
        }

        public void setAllowedExtensions(List<String> allowedExtensions) {
            this.allowedExtensions = allowedExtensions;
        }

        public List<String> getForbiddenExtensions() {
            return forbiddenExtensions;
        }

        public void setForbiddenExtensions(List<String> forbiddenExtensions) {
            this.forbiddenExtensions = forbiddenExtensions;
        }
    }

    public static class Performance {
        private int scanTimeout = 5000; // 毫秒
        private int maxItems = 1000;

        public int getScanTimeout() {
            return scanTimeout;
        }

        public void setScanTimeout(int scanTimeout) {
            this.scanTimeout = scanTimeout;
        }

        public int getMaxItems() {
            return maxItems;
        }

        public void setMaxItems(int maxItems) {
            this.maxItems = maxItems;
        }
    }
}